package com.htl.io.字符流;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;

/**
 *  输入字符流 Reader
 */

public class Reader__test {
    public static void main(String[] args) {
        Reader reader = null;
        try {
            // 获取Reader
//            reader = new FileReader("D:\\Project\\IDEA_project\\java_note\\src\\com\\htl\\io\\test1.txt");
            reader = new FileReader("D:\\Project\\IDEA_project\\java_note\\src\\com\\htl\\io\\test.txt");

            // 开始读取数据
//            int temp = 0;
//            while ((temp = reader.read()) != -1) {
//                System.out.println(temp);
//            }


            char[] chars = new char[30];
//            int read = reader.read(chars);
            int read = reader.read(chars,2,5);
            System.out.println(read);
            for (char aChar : chars) {
                System.out.println(aChar);
            }


        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                // 关闭数据流
                reader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}
